package com.example.springtest;

import com.example.springtest.service.Car;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Map;

/**
 * @title: Test
 * @Author xu-xiang
 * @Date: 2023/8/29 11:35
 * @description:
 */
public class Test {

    public static void main(String[] args) throws Exception {
        ApplicationContext context = new AnnotationConfigApplicationContext(config.class);
        Map<String, Car> beansOfType = context.getBeansOfType(Car.class);
        System.out.println("beansOfType = " + beansOfType);

        Car bean = context.getBean(Car.class);
        bean.showBrand();

        ((Car) context.getBean("carFactoryBean")).showBrand();
    }
}
